<h2> SFX Record</h2>
<?php
$id = rv('id');
if (!$id)
    die('no id?');
$ruleset = get_record($id);
$doms = array();
foreach ($ruleset['domains'] as $d) {
    $doms[] = $d[0];
}
$sql = "
	SELECT `title`,`id`
	FROM `record`,`domain`
	WHERE `domain`.`domain` IN('"
        . implode("','", $doms)
        . "')
	AND `domain`.`record_id`=`record`.`id`
	AND `record`.`source` != 'SFX'
";
$tres = safe_query($sql);
$superseded = false;
if (mysql_num_rows($tres) > 0) {
    $title = mysql_fetch_assoc($tres);
    $id = $title['id'];
    $title = $title['title'];
    $superseded = true;
}
if (!$superseded) {
?>
    <form action="" method="post">
        <input type="hidden" name="action" value="update" />
        <input type="hidden" name="what" value="sfx" />
        <input type="hidden" name="id" value="<?php echo $id; ?>" />
        <p>
            <label><input class="nodisable" type="checkbox" name="enabled" value="1" <?php if ($ruleset['active'])
        echo 'checked="checked" '; ?>/> Record is enabled</label>
            <!--<label><input type="checkbox" name="autologin" value="1" <?php if ($ruleset['autologin'])
        echo 'checked="checked" '; ?>/> Autologin</label>-->
            <br />

            <input class="nodisable" type="submit" value="Save" />
            <br />
        </p>
        <input class="nodisable" type="hidden" name="id" value="<?php echo $id; ?>" />
    </form>
<?php
}else {
?>
    <p>This SFX record is superseded by the local record with title <q><a href="index.php?action=edit&what=item&id=<?php echo $id; ?>"><?php echo htmlspecialchars($title); ?></a></q>.</p>
<?php
}
?>
<p>
    Title: <?php echo htmlspecialchars($ruleset['title']); ?><br />
    URL: <?php echo htmlspecialchars($ruleset['url']); ?>
</p>
Domain(s):<ul>
    <?php
    foreach ($ruleset['domains'] as $d) {
        echo(
        '<li>' . htmlspecialchars($d[0]) . '</li>'
        );
    }
    ?>
</ul>
Host(s):<ul>
    <?php
    foreach ($ruleset['hosts'] as $d) {
        echo(
        '<li>' . htmlspecialchars($d[0]) . '</li>'
        );
    }
    ?>
</ul>
<a href="index.php">&laquo; Back</a>
